/*
739. 每日温度
https://leetcode.cn/problems/daily-temperatures/description/
中等 2024/12/04
*/

class Solution {
public:
    vector<int> dailyTemperatures(vector<int>& temperatures) {
        vector<int>arr(temperatures.size(),0);
        stack<int>se;
        se.push(0);
        int i;
        for(i=1;i<temperatures.size();i++)
        {
            while(!se.empty()&&temperatures[se.top()]<temperatures[i])
            {
                arr[se.top()]=i-se.top();
               se.pop();
            }
            se.push(i);
        }
        return arr;
    }
};